import tensorflow as tf

print(tf.__version__)

import pandas as pd

data = pd.read_csv("../dataset/adv.csv")
print(data.head())

import matplotlib.pyplot as plt

plt.close()
plt.scatter(data.TV, data.sales)
plt.show()
plt.scatter(data.radio, data.sales)
plt.show()

plt.scatter(data.newspaper, data.sales)
plt.show()

x = data.iloc[:, 0:-1]
print(x)
y = data.iloc[:, -1]

model = tf.keras.Sequential(
    [tf.keras.layers.Dense(10, input_shape=(3,),
                           activation='relu'),
     tf.keras.layers.Dense(1)]
)

print(model.summary())
# TODO: optimizer=tf.keras.optimizer.Adam(learning_rate=1e-3),
#           AttributeError: module 'keras.api._v2.keras' has no attribute 'optimizer'
model.compile(optimizer='adam',
              loss='mse')


model.fit(x, y, epochs=100)

test = data.iloc[:10, 0:-1]
print(model.predict(test))
